package recursion;

import java.util.Scanner;

//汉诺塔
public class HanoiTower {
    public static void main(String[] args) {
        while (true) {
            System.out.println("玩几层汉诺塔");
            int n = new Scanner(System.in).nextInt();
            f(n);
        }
    }

    private static void f(int n) {
        f(n, "A", "B", "C");
    }

    private static void f(int n, String from, String mid, String to) {
        if (n == 1) {
            System.out.println(from + "->" + to);
            return;
        }
        f(n - 1, from, to, mid); //n-1就是简化汉诺塔的层数
        f(1, from, mid, to);
        f(n - 1, mid, from, to);
    }
}
